package org.fnzn.web.fngl;

import org.apache.log4j.Logger;
import org.fnzn.aop.SystemControllerLog;
import org.fnzn.bean.FnglGrade;
import org.fnzn.bean.vo.User;
import org.fnzn.core.Page;
import org.fnzn.core.Result;
import org.fnzn.service.FnglGradeService;
import org.fnzn.util.CommonUtil;
import org.fnzn.web.SysLogController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 *绩效信息管理
 */
@RestController
@RequestMapping(value = "/fnglGrade")
@EnableAutoConfiguration
public class FnglGradeController {
    Logger log = Logger.getLogger(SysLogController.class);

    @Autowired
    private FnglGradeService fnglGradeService;

    @RequestMapping(value = "/list",produces = "application/json;charset=UTF-8",method = RequestMethod.GET)
    @SystemControllerLog(description="查询绩效记录")
    public Result findFnglGrade(FnglGrade fnglGrade, Page page){
        return fnglGradeService.findFnglGrade(fnglGrade,page);
    }

    @RequestMapping(value = "/update",produces = "application/json;charset=UTF-8",method = RequestMethod.PUT)
    @SystemControllerLog(description="修改绩效记录")
    public Result updateFnglGrade(FnglGrade fnglGrade){
        return  fnglGradeService.updateFnglGrade(fnglGrade);
    }

    /**
     *  根据销售人员id获取到绩效详情
     */
    @RequestMapping(value = "/getGradeDetail",produces = "application/json;charset=UTF-8",method = RequestMethod.GET)
    @SystemControllerLog(description = "获取到绩效详情")
    public Result getGradeDetail(FnglGrade fnglGrade,Page page){
        return fnglGradeService.getGradeDetail(fnglGrade,page);
    }

    /**
     *  获取到我的绩效
     */
    @RequestMapping(value = "/getMyGrade",produces = "application/json;charset=UTF-8",method = RequestMethod.GET)
    @SystemControllerLog(description = "获取到我的绩效")
    public Result getMyGrade(){
        User user = CommonUtil.getUser();
        return fnglGradeService.getMyGrade(user.getUser_id());
    }

}
